package com.atguigu.tingshu.dispatch.job;

import com.atguigu.tingshu.search.client.SearchFeignClient;
import com.atguigu.tingshu.user.client.UserFeignClient;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class DispatchHandler {

    @Autowired
    private SearchFeignClient searchFeignClient;


    /**
     * 每隔6小时触发一次：更新Redis小时榜数据任务
     */
    @XxlJob("updateLatelyAlbumRanking")
    public void updateLatelyAlbumRanking(){
        log.info("更新Redis小时榜数据任务执行了");
        searchFeignClient.updateLatelyAlbumRanking(20);
    }


    @Autowired
    private UserFeignClient userFeignClient;


    /**
     * 每天凌晨0点触发：更新会员标识
     */
    @XxlJob("updateVipExpireStatus")
    public void updateVipExpireStatus(){
        log.info("更新会员标识任务执行了");
        userFeignClient.updateVipExpireStatus();
    }

}
